Repository navigation
fix(sandbox): scope quota cleanup to the sandbox owner - #1153
Merged
Merged
Conversation
Contributor
Review posted for
|
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
all-hands-bot
approved these changes
Nov 3, 2026
Contributor
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
The fix is correct, and I found no material issues.
What I checked
- Root cause.
secure_selectreturns every row forADMIN. Before this change, quota cleanup under anADMINcontext, such as the Slack resume path inintegrations/slack/slack_view.py, counted and paused the oldest running remote sandboxes of all users._get_user_running_sandboxesnow always filters oncreated_by_user_id == owner_user_id.resume_sandboxpasses the stored owner of the target sandbox. The start path still uses the caller's user id. A non-ADMIN caller is still limited bysecure_select, so an explicitowner_user_idcannot reach rows the caller could not already see.test_explicit_quota_owner_does_not_bypass_caller_accesscovers this. - Ownerless handling. An
ADMINstart or cleanup without an owner now fails before/listor/pause. Before, it paused sandboxes across all users. The 409 on resume of an ownerless paused sandbox is a deliberate trade-off, and the PR notes say so. exclude_id=sandbox_idon resume. This matchesManagedSandboxService.resume_sandbox. It stops a target that becomes running during cleanup from being counted against the limit, or paused by its own resume. Theconcurrent_resumecase covers this.- Other entry points. Docker, E2B and K8s already require a user id before they call
pause_old_sandboxes, so this change brings the remote backend in line with them.
Validation
- In the workspace with the repository PostgreSQL fixture, I ran the four test files from the PR at the head commit: 166 passed.
- I ran the new
test_remote_sandbox_quota_ownership.pyagainst themainservice: 9 cases fail and 5 pass. Some of the failures come from the newowner_user_idkeyword. The multi-owner, ownerless andADMINstart cases fail on behavior. - All GitHub Actions checks on
358ca1b8c85bpass, including the four Python test shards, Lint python and Budget regressions.
✅ APPROVED
LLM profile: all-hands-bot-reviewer_claude-opus-5-5 · Model: openhands/claude-opus-5-5
ak684
marked this pull request as ready for review
November 3, 2026 18:05
ak684
enabled auto-merge (squash)
November 3, 2026 18:10
Contributor
|
🚀 Released in 1.85.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
AGENT:
Why
An ADMIN-context resume can apply one user's sandbox quota to every running remote sandbox because ADMIN can read every owner's database rows. Resuming one paused sandbox can therefore pause unrelated users' work in OHE or SaaS deployments using this backend.
Summary
Issue Number
Fixes OSS-15057.
How to Test
Run
uv run pytest -q tests/unit/app_server/test_remote_sandbox_quota_ownership.py tests/unit/app_server/test_remote_sandbox_service.py tests/unit/app_server/test_sandbox_resume_git_config.py tests/unit/integrations/slack/test_slack_view.pywith the repository PostgreSQL fixture: 166 passed. Eight regression cases fail against the original service. Pre-commit checks, including mypy, pass.Live OHE/Replicated test: executed the exact candidate service in an isolated app-pod process against real PostgreSQL and runtime pods. An ADMIN resume paused only the owner's oldest sandbox; another owner's sandbox and background process survived. Trial resources were cleaned and app configuration preserved. Packaged rollout and browser/integration end-to-end testing remain.
Video/Screenshots
Backend-only change; assertions checked the runtime mutation sequence and the unrelated process's PID/start time.
Type
Notes
No migrations or configuration changes. Ownerless paused sandboxes now return 409. The owner's oldest-running policy is unchanged: idle-only selection and concurrent quota serialization remain follow-ups.
Enterprise server image for this PR: